package dao

import (
	"github.com/jinzhu/gorm"
	_ "github.com/jinzhu/gorm/dialects/mysql"
	"log"
)

var DB *gorm.DB

func Setup() {
	var err error
	DB, err = gorm.Open("mysql", "tp:yjy6560963ab@(47.93.4.59:3306)/tp")
	if err != nil {
		log.Panicln("err:", err)
		return
	}

	DB.DB().SetMaxIdleConns(10)
	DB.DB().SetMaxOpenConns(2)
}

func Close() {
	DB.Close()
}
